home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1997: The Complete Utilities Toolkit / macworld-complete-utilities-1997.iso / Programming / Little Smalltalk v3.1.5 / C Source / Sources / st.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-14  |  2.9 KB  |  145 lines  |  [TEXT/KAHL]

  1. /*
  2.     Little Smalltalk, version 3
  3.     Main Driver
  4.     written By Tim Budd, September 1988
  5.     Oregon State University
  6. */
  7. # include <stdio.h>
  8. # include <stdlib.h>
  9. # include <string.h>
  10. # include "env.h"
  11. # include "memory.h"
  12. # include "names.h"
  13.  
  14. #ifdef THINKC
  15. # ifdef TCL
  16. #   include "macio.h"
  17. #   include "glue.h"
  18. #   include "tclprim.proto.h"
  19. # else
  20. #   include "winprim.proto.h"
  21. #   include "unixio.proto.h"
  22. # endif
  23. # include "st.proto.h"
  24. # include "interp.proto.h"
  25. # include "memory.proto.h"
  26. # include "names.proto.h"
  27. #endif
  28.  
  29. int initial = 0;    /* not making initial image */
  30.  
  31. extern int objectCount();
  32.  
  33. # ifdef NOARGC
  34.  
  35.  
  36. main (void)
  37. # endif
  38. {
  39. #ifdef TCL
  40. FILE        fp;
  41. #else
  42. FILE        *fp;
  43. #endif
  44. object        firstProcess;
  45. char        *p, buffer[120];
  46. #ifdef STDWIN             /* also TCL */
  47. short        yncResponse;            /* JRB - 5/94 */
  48. long        errNo;                    /* JRB - 5/94 */
  49. CURSOR        *csr;                    /* JRB - 5/94 */
  50. #endif
  51.  
  52. initMemoryManager();
  53.  
  54. strcpy(buffer,"systemImage");
  55. p = buffer;
  56.  
  57. # ifdef STDWIN             /* also TCL */
  58. /* initialize the standard windows package */
  59.     winit();
  60.     wmenusetdeflocal(1);
  61.  
  62. # ifdef NOARGC
  63. # ifdef TCL                /* Deal with any initial OpenDocument AppleEvents JRB - 7/94 */
  64.     if (processStartUpEvent (buffer) )                                        
  65.         p = buffer;
  66.     else
  67. #endif
  68. /* ======================== JRB - 7/94 */
  69.     {
  70.         yncResponse = waskync ("use default initial object image?", 1);
  71.         switch (yncResponse)  {
  72.             case 0:                /* No */
  73. # ifdef TCL
  74.                 waskfile("Image file name:", buffer, 120, 0, 2);
  75. # else
  76.                 waskfile("Image file name:", buffer, 120, 0);
  77. # endif
  78.                 p = buffer;
  79.                 break;
  80.             case -1:            /* Cancel */
  81.                 sysError ("Image load cancelled", " - Aborting start-up.");
  82.                 break;
  83.             default:             /* Yes */
  84.                 p = "systemImage";
  85.         }
  86.     }                                                                    
  87. /* =================================== */
  88. # endif
  89. # endif
  90.  
  91. # ifndef NOARGC
  92.     if (argc != 1) p = argv[1];
  93. # endif
  94.  
  95. #ifndef TCL
  96. # ifdef BINREADWRITE
  97.     fp = fopen(p, "rb");
  98. # endif
  99. # ifndef BINREADWRITE
  100.     fp = fopen(p, "r");
  101. # endif
  102.     if (fp == NULL) {
  103.         sysError("cannot open image", p);
  104.     exit(1);
  105.     }
  106.     imageRead(fp);
  107. #else    /* ======================== Mac-specific image read JRB - 5/94 */
  108.     errNo = openFile (&fp, p, "r", 0);
  109.     if (errNo != 0) {
  110.         sysError ("cannot open image: ", p);
  111.         exit (1);
  112.     }
  113.     csr = wfetchcursor ("watch");
  114.     wsetwincursor ((WINDOW *)0L, csr);
  115.     imageRead (fp.fileRef);
  116.     closeFile (&fp, p);
  117. #endif
  118.  
  119.     initCommonSymbols();
  120.     
  121.     firstProcess = globalSymbol("systemProcess");
  122.     if (firstProcess == nilobj) {
  123.         sysError("no initial process","in image");
  124.         exit(1); return 1;
  125.     }
  126.     
  127.     /* execute the main system process loop repeatedly */
  128.     /*debugging = true;*/
  129.     
  130. # ifndef STDWIN
  131.     /* not using windowing interface, safe to print out message */
  132.     printf("Little Smalltalk, Version 3.04\n");
  133.     printf("Written by Tim Budd, Oregon State University\n");
  134. # endif
  135.  
  136.     while (execute(firstProcess, 15000)) ;
  137.     
  138. # ifdef STDWIN
  139.     wdone();
  140. # endif
  141.  
  142. /* exit and return - belt and suspenders, but it keeps lint happy */
  143.     exit(0); return 0;
  144. }
  145.